;##################################
;命令：
;nasm -f elf64 day7_0vector_0shuffle_1hex.asm -o main.o && gcc main.o -o main -lc -no-pie && ./main
;输出：
;Value in arr[0] is 1.111100.
;Value in arr[1] is 4.444400.
;Value in arr[2] is 6.666600.
;Value in arr[3] is 7.777700.
;##################################
extern printf

section .data
	msg: db `Value in arr[%d] is %f.\n`, 0
	arr0: dd 1.1111, 2.2222, 3.3333, 4.4444
	arr1: dd 5.5555, 6.6666, 7.7777, 8.8888

section .text
	global main

main:
	push rbp
	mov rbp, rsp

;#####################################################
	vmovups xmm0, [arr0]
	vmovups xmm1, [arr1]
	;写成二进制较为繁琐，可以直接写为十六进制
	;显然，人类是不可能直接写出十六进制的
	;vshufps xmm0, xmm0, xmm1, 10011100b
	vshufps xmm0, xmm0, xmm1, 9ch
	vmovups [arr0], xmm0
;#####################################################

	;打印
	mov ebx, 0
	jmp compare

execute:
	mov rdi, msg
	movsxd rsi, ebx
	cvtss2sd xmm0, dword [arr0 + 4 * ebx]
	movq rdx, xmm0
	call printf

	inc ebx

compare:
	cmp ebx, 4
	jl execute

	mov eax, 0
	leave
	ret
